<!DOCTYPE html>

<html>
<head id="index">
    <style type="text/css">
        #fm {
            margin: 0;
            padding: 10px 30px;
        }

        .ftitle {
            font-size: 14px;
            font-weight: bold;
            color: #666;
            padding: 5px 0;
            margin-bottom: 10px;
            border-bottom: 1px solid #ccc;
        }

        .fitem {
            margin-bottom: 5px;
        }

        .fitem label {
            display: inline-block;
            width: 80px;
        }
    </style>

    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
    <title></title>

    <script type="text/javascript" src="/jslib/jquery-easyui-1.4.1/jquery.min.js"></script>
    <script type="text/javascript" src="/jslib/jquery-easyui-1.4.1/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="/jslib/jquery-easyui-1.4.1/locale/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript" src="/page/init.js"></script>
    <script type="text/javascript" src="/jslib/jsUtil.js"></script>
    <link rel="stylesheet" href="/jslib/jquery-easyui-1.4.1/themes/default/easyui.css"/>
    <link rel="stylesheet" href="/jslib/jquery-easyui-1.4.1/themes/icon.css"/>


</head>
<body class="easyui-layout">
<div id="loginDialog" class="easyui-dialog" data-options="title:'登录',closable:false,modal:true,
			buttons:[{
				text:'登录',
				handler:function(){

				   loginTest()
				}
			},{
				text:'注册',
				handler:function(){
				      $('#regDialog input').val('')
                    $('#regDialog').dialog('open')
				}
			}]">

    <form id="loginInputForm" method="post">
        <table>
            <tr>
                <th> 用户名</th>
                <td><input type="" name="name" value="admin"/></td>
            </tr>
            <tr>
                <th> 密码</th>
                <td><input type="password" name="passwd" value="1"/></td>
            </tr>

        </table>
    </form>

</div>
<div id="regDialog" class="easyui-dialog" data-options="title:'注册',closable:true,closed:'true',modal:true,
			buttons:[{
				text:'注册',
				iconCls:'icon-edit',
				handler:function(){
				    addUser()
				}
			}]">

    <form id="regInputForm" method="post">
        <table>
            <tr>
                <th> 用户名</th>
                <td><input id="name" name="name" class="easyui-validatebox" data-options="required:true"/></td>
            </tr>
            <tr>
                <th> 密码</th>
                <td><input type="password" id="passwd" name="passwd" class="easyui-validatebox" data-options="required:true"/></td>
            </tr>
            <tr>
                <th> 重复密码</th>
                <td><input type="password" id="repasswd" name="repasswd" class="easyui-validatebox" data-options="required:true,
               validType:'eqPwd[\'#passwd\']'"/></td>
            </tr>

        </table>
    </form>

</div>
<div data-options="region:'north',title:'',split:true" style="overflow: hidden; height: 60px;"></div>
<div data-options="region:'south',title:'',split:true" style="height:28px;"></div>
<div data-options="region:'east',iconCls:'icon-reload',title:'East',split:true,border:true" style="width:100px;"></div>
<div data-options="region:'west',title:'...',split:true" style="width:180px;">

    <!--  导航内容 -->
    <div id="navmenu" class="easyui-accordion" data-options="fit:'true',border:false">

        <div title="系统管理">
            <ul id="nav" class="easyui-tree"/>

            </ul>
        </div>
        <div title="常用工具"></div>
    </div>


</div>
<div id="mainPanle" region="center" title="">
    <div id="index_tabs" class="easyui-tabs" fit="true" border="false">
        <div title="欢迎!">

        </div>
        <div title="welcome!!">

        </div>
    </div>
</div>
<script type="text/javascript">
    var loginDialog;
    $(function () {
        $('#regInputForm input').bind('keyup', function (event) {
            if (event.keyCode == '13') {/*绑定回车*/
                $('#regInputForm').submit();
            }
        })
        $('#loginInputForm input[name=name]').focus()
        initNavMenu();
    })
    function addUser() {
        $('#regInputForm').form('submit', {
            url: "/login/adduser.do",
            success: function (res) {
                var r = jQuery.parseJSON(res)
                if (r.success) {
                    $('#regDialog').dialog('close')
                    $('#loginDialog').dialog('close')
                    $.messager.show({
                        title: '我的消息',
                        msg: r.msg

                    });

                }
            }
        });
    }
    function loginTest() {

        $('#loginInputForm').form('submit', {
            url: "/login/logintest.do",
            success: function (res) {
                var r = jQuery.parseJSON(res)
                if (r.success) {
                    $('#regDialog').dialog('close')
                    $('#loginDialog').dialog('close')
                    $.messager.show({
                        title: '我的消息',
                        msg: r.msg

                    });

                }
            }
        })
    }
    function initNavMenu() {
        $("#nav").tree({
            url: '${pageContext.request.contextPath}' + '/initleft/gettreeall.do',
            parentField : 'pid',
            selected: true,
            lines:true,
            onClick: function (node) {
                //如果没有地址就不打开页面
                console.info(node)
                if (node.attributes.url) {
                   var url='${pageContext.request.contextPath}'+node.attributes.url
                    addTab({title: node.text, href: url, closable: true});  // 在用户点击的时候提示
                }

            }
        })
    }
    function addTab(opts){
        console.info(opts)
        var t=$("#index_tabs")
        if(t.tabs('exists',opts.title)) {
            t.tabs('select',opts.title)
        }else{
            t.tabs('add',opts)

        }


    }
</script>
</body>
</html>